import {
    ajaxPost,
    showToast
} from '../../../utils/util'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        workSource: []
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            id: options.id
        })
        this.getWork()
    },
    getWork() {
        let data = {
            token: wx.getStorageSync('token'),
            position_id: this.data.id,
        }
        ajaxPost('/authuser/sendpositionlist', data, res => {
            if (res.code == 0) {
                this.setData({
                    workSource: res.data.list
                })
            }
        })
    },
    /**
     * 一键投递
     */
    send() {
        let idArr = []
        this.data.workSource.map((item) => {
            idArr.push(item.id)
        })
        let idStr = idArr.join(',');
        let data = {
            token: wx.getStorageSync('token'),
            position_ids: idStr,
        }
        ajaxPost('/authuser/xxSendResumes', data, res => {
            if (res.code == 0) {
                showToast('text', '投递成功')
                this.getWork()
            }
        })
    },
})